<include file="Public/header"/>
<div class="row">
    <div class="ibox-content">
        <div class="deal-bd order-bottom">提款管理</div>
        <form class="layui-form" action="" method="get" autocomplete="off" id="withdrawalform">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" name="memberid" autocomplete="off" placeholder="请输入商户号"
                           class="layui-input" value="<{$_GET['memberid']}>" lay-key="1">
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" class="layui-input" name="createtime" id="createtime"
                           placeholder="申请起始时间" value="<{$_GET['createtime']}>" lay-key="1">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline" style="width:200px;">
                    <select name="status">
                        <option value="">全部状态</option>
                        <option <if condition="$_GET['status'] neq '' && $_GET['status'] eq 0">selected
                    </if> value="0">未处理</option>
                        <option <if condition="$_GET['status'] eq 1">selected</if> value="1">处理中</option>
                        <option <if condition="$_GET['status'] eq 2">selected</if> value="2">已打款</option>
                        <option <if condition="$_GET['status'] eq 3">selected</if> value="3">已驳回</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width:200px;">
                    <select name="paf">
                        <option value="">全部通道</option>
                        <foreach name="paf_lists_all" item="vo">
                            <option <?php if($_GET['paf'] == $vo['id']) echo 'selected';?> value="<{$vo.id}>"><{$vo.title}></option>
                        </foreach>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button type="submit" class="layui-btn layui-bg-blue"><i class="fa fa-search"></i> 搜索</button>
                <a href="javascript:;" id="submitAllOrder" class="layui-btn layui-bg-blue"><i class="fa fa-user"></i> 提交代付</a>
                <a href="javascript:;" id="export" class="layui-btn layui-bg-green"><i class="fa fa-clipboard"></i> 导出数据</a>
                <a href="javascript:;" id="delorder" onclick="chooseOrder_del()" class="layui-btn layui-btn-danger"><span class="glyphicon glyphicon-trash"></span> 删除上月记录</a>
            </div>
            <div class="container-fluid bg-gray" style="margin-top:10px;" >
                <div class="row">
                    <div class="col-xs-6 col-md-4 ">
                        <div class="num-box" style="margin:0;padding:10px;">
                            <div class="left-img"><img src="Public/Front/img/order.png" alt=""></div>
                            <div class="right-num">
                                <p class="num-title">已打款金额</p>
                                <p class="main-num"><{$tkmoneysum}> 元</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6 col-md-4 ">
                        <div class="num-box" style="margin:0;padding:10px;">
                            <div class="left-img"><img src="Public/Front/img/order.png" alt=""></div>
                            <div class="right-num">
                                <p class="num-title">已打款笔数</p>
                                <p class="main-num"><{$number}> 笔</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!---->
    <!---->
    <!---->
    <!--条件筛选过滤-->
    <div style="margin-left:20px;">
        <button  class="btn btn-primary" data-toggle="modal" data-target="#myModal">筛选一下</button>
    </div>
    <div class="tablediv">
        <table class="table table-hover choosetable">
            <thead>
            <tr>
                <th>商户编号</th>
                <th>姓名</th>
                <th>结算金额</th>
                <th style="display:none">到账金额</th>
                <th>银行名称</th>
                <th>支行名称</th>
                <th>银行卡号</th>
                <th>开户名</th>
                <th>状态</th>
                <th>代付渠道</th>
                <th>申请时间</th>
                <th>处理时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="list" id="vo">
            <tr>
                <td><{$vo["userid"]+10000}></td>
                <td><{$vo["realname"]}></td>
                <td><{$vo["tkmoney"]}> 元</td>
                <td style="display:none"><{$vo["money"]}> 元</td>
                <td><{$vo.bankname}></td>
                <td><{$vo.bankzhiname}></td>
                <td><{$vo.banknumber}></td>
                <td><{$vo.bankfullname}></td>
                <td>
                    <switch name="vo.status">
                        <case value="0"><span style="color:#F00;">未处理</span></case>
                        <case value="1"><span style="color:#06F;">处理中</span></case>
                        <case value="2"><span style="color:#060;">已打款</span></case>
                        <case value="3"><span class="text-danger">已驳回</span></case>
                        <default />
                    </switch>
                </td>
                <td>
                    <if condition="$vo['status'] eq 0">
                        <select lay-ignore=''  style="width: 80px;height: 30px;">
                            <option>请选择</option>
                            <foreach name="pfa_lists" item="v">
                                <option value="<{$v.id}>" <if condition="$v[is_default] eq 1">selected</if> ><{$v.title}></option>
                            </foreach>
                        </select>
                        <else / >
                        <{$vo.df_name}>
                    </if>
                </td>
                <td><{$vo.sqdatetime}></td>
                <td><{$vo.cldatetime}></td>
                <td>
                    <if condition="$vo['status'] lt 2">
                        <a class="layui-btn layui-btn-warm layui-btn-mini" onclick="set_wtop('结算商户编号:<{$vo.userid}>','<{:U('Admin/Withdrawal/editwtStatus',['id'=>$vo[id]])}>',510,280)">设置</a>
                    </if>
                    <if condition="$vo['status'] eq 0">
                        <a class="layui-btn layui-btn-warm layui-btn-mini" onclick="submitPayment(this, '<{$vo[id]}>','exec')" >提交代付</a>
                    </if>
                    <if condition="$vo['status'] eq 1">
                        <a class="layui-btn layui-btn-warm layui-btn-mini" onclick="submitPayment(this, '<{$vo[id]}>','query')">代付查询</a>
                    </if>
                </td>
            </tr>
            </volist>
            </tbody>
        </table>
        <div class="pagex"> <{$page}></div>
    </div>


    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">筛选条件</h4>
                </div>
                <div class="modal-body"></div>
                <div style="clear: both;"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button id="choosebtn" type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                </div>
            </div>
        </div>
    </div>
</div>
<include file="Public/footer"/>
<script>
    layui.use(['laydate', 'laypage', 'layer', 'table', 'form'], function() {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            ,layer = layui.layer //弹层
            ,form = layui.form //表单
            , table = layui.table; //表格
        //日期时间范围
        laydate.render({
            elem: '#createtime'
            , type: 'datetime'
            ,theme: 'molv'
            , range: '|'
        });
        //日期时间范围
        laydate.render({
            elem: '#successtime'
            , type: 'datetime'
            ,theme: 'molv'
            , range: '|'
        });
        //         监听checkbox复选
        form.on('checkbox(encrypt)', function(data){
            console.log(data.othis.length)

            console.log(data.elem); //得到checkbox原始DOM对象
            console.log(data.elem.checked); //是否被选中，true或者false
            console.log(data.value); //复选框value值，也可以通过data.elem.value得到
            console.log(data.othis); //得到美化后的DOM对象

        });

    });
    /*订单-查看*/
    function set_wtop(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
    $('#export').on('click',function(){
        window.location.href
            ="<{:U('Admin/Withdrawal/exportweituo',array('memberid'=>$_GET[memberid],'T'=>$_GET[T],'createtime'=>$_GET[createtime],'successtime'=>$_GET[successtime],'tongdao'=>$_GET[tongdao],'status'=>$_GET[status]))}>";
    });
    function submitPayment(obj, id, name) {
        var select_obj = $(obj).parent().parent().find('select');
        var code = select_obj.val();
        console.log(code);
        if(typeof(code)=="undefined")
            code = 'query';
        layer.confirm('确认要提交吗？',function(index) {
            $.ajax({
                url: "<{:U('Payment/Index/index',array(), false)}>",
                type: 'post',
                data: {'id':id ,'opt':name, 'code':code},
                success: function (res) {
                    console.log(res);
                    if (res.status == 'success') {
                        layer.msg('已成功提交!', {icon: 1, time: 1000},function () {
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(res.msg, {icon: -1, time: 4000},function () {
                            // location.replace(location.href);
                        });
                    }
                }
            });
        });
    }

    // $('#submitAllOrder').on('click', function(){
    //     var id = '';
    //     $('.checkIds').each(function(){
    //         var _this = $(this);
    //         if( _this.is(':checked')  ){
    //             id = id + _this.val() + ',';
    //         }
    //     });
    //     if(id){
    //         layer.confirm('确认要提交吗？',function(index) {
    //             $.ajax({
    //                 url: "<{:U('Payment/Index/index',array(), false)}>",
    //                 type: 'post',
    //                 data: {'id':id ,'opt':'exec','code':'default'},
    //                 success: function (res) {
    //                     if (res.status!='error') {
    //                         layer.msg('已成功提交!', {icon: 1, time: 1000},function () {
    //                             location.replace(location.href);
    //                         });
    //                     }else{
    //                         layer.msg(res.msg, {icon: 2, time: 1000},function () {
    //                             location.replace(location.href);
    //                         });
    //                     }
    //                 }
    //             });
    //         });
    //     }else{
    //         layer.msg('请选择订单号', {icon: 2, time: 1000},function () {});
    //     }
    // });

    // $('#checkAll').on('click', function(){
    //     var child = $('table').next().find('tbody input[type="checkbox"]');  ;
    //     child.each(function(){
    //         $(this).attr('checked', true);
    //     });
    //     $('.layui-form-checkbox').addClass('layui-form-checked');
    //
    // });
    function chooseOrder_del() {
        var now = new Date();
        layer.confirm('删除操作为真实删除，确定要删除吗？',function(index){
            $.ajax({
                url:"<{:U('Withdrawal/delOrder')}>",
                type:'post',
                data:{},
                success:function(res){
                    if(res.status){
                        layer.alert(res.msg,function () {
                            location.replace(location.href);
                        });
                    }else{
                        layer.alert(res.msg);
                    }
                }
            });
        });
    }
</script>
<script type="text/javascript">
    $(function(){
        //要绑定的表格类名
        var choosetable=".choosetable";
        var checkarray=[];
        //循环遍历table的th加入到筛选列表中
        $(choosetable+" th").each(function(){
            checkarray.push($(this).text());
        });
        for (var i = 0; i < checkarray.length/3; i++) {
            if(i<checkarray.length/3-1||checkarray.length%3==0){
                var checktext="";
                for (var j = 0; j < 3; j++) {
                    checktext+="<div class='choosediv'>" +
                        "<label class='checkbox' style='padding-left:60px;text-align: left;'>" +
                        "<input style='margin-top:3px;' type='checkbox'  value='"+((i*3)+j)+"'>"+checkarray[((i*3)+j)]+" " +
                        "</label>" +
                        "</div>";
                }
            }else{
                var checktext="";
                for (var j = 0; j <checkarray.length%3; j++) {
                    // console.log(checkarray.length);
                    checktext+="<div class='choosediv'>" +
                        "<label class='checkbox' style='padding-left:60px;text-align: left;'>" +
                        "<input style='margin-top:3px;' type='checkbox' value='"+((i*3)+j)+"'> "+checkarray[((i*3)+j)]+" " +
                        "</label> " +
                        "</div>";
                }
            }
            $(".modal-body").append("<div class='chooses'>"+checktext+"</div>");
        }
        $("#choosebtn").click(function(){
            var choosearr=[];
            $(".checkbox input").each(function(){
                // alert(typeof $(this).is(":checked"));
                if(!$(this).is(":checked")){
                    choosearr.push($(this).val());
                }
            });
            $(choosetable+" tr").each(function(){
                $(this).children().show();
            });
            for(var i=0;i<choosearr.length;i++){
                $(choosetable+" tr").each(function(){
                    $(this).children().eq(choosearr[i]).hide();
                });
            }
        });
    })
</script>
</body>
</html>